﻿package org.utils 
{
	/**
	 * 时间格式化类，单位为毫秒数 
	 * @author Administrator
	 * 
	 */	
	public class TimeFormat 
	{
		
		public function TimeFormat() 
		{
			
		}
		/**
		 * 将毫秒转化成分钟和秒的形式 
		 * @param value 毫秒数
		 * @return 
		 * 
		 */		
		public static function m_s(value:Number):String
		{
			var minutes:String=String(Math.floor(value/60))
			var seconds:String =String( Math.floor(value % 60))
			if (minutes.length < 2)minutes="0"+minutes
			if (seconds.length < 2) seconds = "0" + seconds
			return minutes + ":" + seconds
			
			}
		
		/**
		 * 将毫秒转化成天，小时和分钟形式 
		 * @param value 毫秒数
		 * @return String
		 * 
		 */		
		public static function d_h_m(value:Number):String
		{
			var day:String = String( Math.floor(value / (1000 * 60 * 60 * 24)))
			
			var hours:String=String(Math.floor(value % (1000 * 60 * 60 * 24)/(1000 * 60 * 60)))
			
			var minutes:String =String(Math.floor(value % (1000 * 60 * 60 * 24)%(1000 * 60 * 60)/(1000*60)))

			return day + "天" + hours+"小时"+minutes+"分"
			
			}	
			
		/**
		 * 将毫秒转化成年，月，天，小时，分和秒形式 
		 * @param value 毫秒数
		 * @return String
		 * 
		 */		
	   public static function y_m_d_h_m_s(value:Number):String{
	   
	        var date:Date=new Date()
            date.time=value
            
            var y:String=String(date.getFullYear())
            var m:String=String(date.getMonth())
            var d:String=String(date.getDate())
            var h:String=String(date.getHours())
            var mn:String=String(date.getMinutes())
            var s:String=String(date.getSeconds())
            
            y=y.charAt(y.length-2)+y.charAt(y.length-1)
            m=m.length==2?m:"0"+m
            d=d.length==2?d:"0"+d
            h=h.length==2?h:"0"+h
            mn=mn.length==2?mn:"0"+mn
            s=s.length==2?s:"0"+s
            
            return y+"/"+m+"/"+d+" "+h+":"+mn+":"+s;
	   
	   }		
		
	}
	
}